define(["jquery", "easy-admin"], function ($, ea) {

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'coupon.store_coupon/index',
        add_url: 'coupon.store_coupon/add',
        edit_url: 'coupon.store_coupon/edit',
        delete_url: 'coupon.store_coupon/delete',
        export_url: 'coupon.store_coupon/export',
        modify_url: 'coupon.store_coupon/modify',
    };

    var Controller = {

        index: function () {
            ea.table.render({
                init: init,
                cols: [[
                    {type: 'checkbox'},                    {field: 'id', title: '优惠券表ID'},                    {field: 'title', title: '优惠券名称'},                    {field: 'integral', title: '兑换消耗积分值'},                    {field: 'coupon_price', title: '兑换的优惠券面值'},                    {field: 'use_min_price', title: '最低消费多少金额可用优惠券'},                    {field: 'coupon_time', title: '优惠券有效期限（单位：天）'},                    {field: 'sort', title: '排序', edit: 'text'},                    {field: 'status', title: '状态0：关闭，1：开启', templet: ea.table.switch},                    {field: 'add_time', title: '兑换项目添加时间'},                    {field: 'is_check', title: '是否可叠加'},                    {field: 'coupon_type', title: '优惠券类型'},                    {width: 250, title: '操作', templet: ea.table.tool},
                ]],
            });

            ea.listen();
        },
        add: function () {
            ea.listen();
        },
        edit: function () {
            ea.listen();
        },
    };
    return Controller;
});